package ua.kpi_java_training.zabrodskyi.module2;

/**
 * @author Maksym Zabrodskyi
 * @version 10-Jun-2013
 */
public class Position {

    private final int DEFAULT_X = 0;
    private final int DEFAULT_Y = 0;
    private int x;
    private int y;

    public Position() {
        this.x = DEFAULT_X;
        this.y = DEFAULT_Y;
    }

    public Position(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public Position(Position position) {
        this(position.x, position.y);
    }

    public void setPosition(Position position) {
        this.x = position.getX();
        this.y = position.getY();
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    @Override
    public boolean equals(Object object) {
        Position position = (Position) object;
        return position.x == x && position.y == y;
    }

    @Override
    public String toString() {
        return String.format("[%s,%s]", this.x, this.y);
    }

}
